Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free the raw device when wgpu::Device is dropped. #2567

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

jimblandy
Copy link
Member

Go ahead and call global.device_drop from direct::Context::device_drop.

Let Global::device_drop simply drop the life guard's RefCount, and put off everything else entailed in freeing a device until Device::maintain says its queue is empty and there are no more references to it. (The user can reach that function, even after dropping their Device, by calling wgpu::Instance::poll_all.)

Fixes #2563.

This won't have any effect until #2565 is landed as well.

@jimblandy
Copy link
Member Author

This is just a "see if this works" patch; totally open to suggestions for different approaches.

Go ahead and call `global.device_drop` from `direct::Context::device_drop`.

Let `Global::device_drop` simply drop the life guard's `RefCount`, and
put off everything else entailed in freeing a device until
`Device::maintain` says its queue is empty and there are no more
references to it. (The user can reach that function, even after
dropping their `Device`, by calling `wgpu::Instance::poll_all`.)

Fixes gfx-rs#2563.
@kvark kvark merged commit 3bdef1c into gfx-rs:master Apr 1, 2022
@jimblandy jimblandy deleted the free-device branch April 1, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Device::drop doesn't actually free the device when using backend::direct::Context
2 participants